<!--
 * @Description: 
 * @Author: 邹涵
 * @LastEditTime: 2024-06-18 15:28:24
-->
<template>
  <div>
    <el-dialog
      class="fileSynchronization-detail"
      title="储能信息"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="cancel"
      @open="open"
      @close="closeDialog"
    >
      <div class="model-view">
        <div class="content-view">
          <div>
            <div>
              <TitleLook :title="'储能基本信息'"> </TitleLook>
              <div>
                <el-row :gutter="20">
                  <el-col
                    :span="6"
                    v-for="item in detailData"
                    :key="item.index"
                  >
                    <span>{{ item.name }}</span>
                    <span>{{ item.value }}</span>
                  </el-col>
                </el-row>
              </div>
            </div>

            <div>
              <div>
                <div>
                  <TitleLook :title="'指标统计'"> </TitleLook>
                  <div class="underTitle2" style="height: 85%">
                    <div v-for="item in zhibiaoInfo" :key="item.index">
                      <div :class="item.child_left1"></div>

                      <div
                        style="
                          display: flex;
                          flex-direction: column;
                          width: 50%;
                          justify-content: center;
                        "
                      >
                        <div class="child_right" style="font-size: 14px">
                          <span :class="item.class">{{ item.name }}</span>
                        </div>

                        <div
                          class="child_right"
                          style="color: rgb(76, 197, 176)"
                        >
                          <span :class="item.class">{{ item.value }}</span>
                          <span :class="item.class">{{ item.dw }}</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>

                <div>
                  <TitleLook :title="'储能实时状态统计'"> </TitleLook>
                  <div
                    id="vre2"
                    style="width: 100%; height: 90%"
                    ref="vre2"
                  ></div>
                </div>
              </div>
              <TitleLook :title="'储能状态统计'"> </TitleLook>
              <div id="vre1" style="width: 100%; height: 90%" ref="vre1"></div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
  
  <script>
import { init } from "echarts";
import { detailData, zhibiaoInfo } from "../data";
export default {
  name: "add",
  props: {
    dialogVisible: {
      type: Boolean,
      default: () => false,
    },
    diglogObj: {
      type: Object,
      default: () => {},
    },
    title: {
      type: String,
      default: "",
    },
    typeStr: {
      type: String,
      default: "",
    },
  },
  components: {},
  data() {
    return {
      detailData: detailData,
      zhibiaoInfo: zhibiaoInfo,
    };
  },
  mounted() {
    console.log(this.$refs, "8888888");
  },
  methods: {
    /**
     * @Description: 打开dialog
     * @Author: 赵程成
     */
    open() {
      // this.queryData();
      this.$nextTick(() => {
        this.initEchart3();
        this.initEchart2();
      });
    },

    initEchart2() {
        let myChart = this.$echarts.init(document.getElementById("vre2"));

      let dataList = [
        { value: 628, name: "满电时长" },
        { value: 735, name: "剩余电量小于30%时长" },
        { value: 580, name: "其他" },
      ];
      const colorList = ["#4D88FE", "#50CCCB", "#FFBF3C"];
      let option = {
        legend: {
          icon: "circle",
          data: dataList.map((item) => item.name),
        },
        series: [
          {
            type: "pie",
            radius: "70%",
            center: ["50%", "50%"],
            label: {
              fontWeight: "bold",
              rich: {
                rich_blue: {
                  color: "#4D88FE",
                },
                rich_orange: {
                  color: "#FFBF3C",
                },
                rich_green: {
                  color: "#50CCCB",
                },
              },
              formatter: function (params) {
                console.log(params);
                if (params.name === "满电时长") {
                  return (
                    params.name + "\n\n" + `{rich_orange|${params.percent}%}`
                  );
                } else if (params.name === "剩余电量小于30%时长") {
                  return (
                    params.name + "\n\n" + `{rich_green|${params.percent}%}`
                  );
                } else if (params.name === "其他") {
                  return (
                    params.name + "\n\n" + `{rich_blue|${params.percent}%}`
                  );
                }
              },
            },
            labelLine: {
              length: 10,
              length2: 60,
            },
            itemStyle: {
              normal: {
                borderColor: "#fff",
                borderWidth: 2,
                color: function (params) {
                  return colorList[params.dataIndex];
                },
              },
            },
            data: dataList,
          },
        ],
      };
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },

    initEchart3() {
      let myChart = this.$echarts.init(document.getElementById("vre1"));
      let option = {
        backgroundColor: "#fff",
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        grid: {
          left: "2%",
          right: "4%",
          bottom: "10%",
          top: "20%",
          containLabel: true,
        },
        legend: {
          data: ["充电量", "放电量"],
          top: "8%",
          textStyle: {
            // color: "#fff",
            fontSize: 16,
          },
          itemWidth: 12,
          itemHeight: 10,
          // itemGap: 35
        },
        xAxis: {
          type: "category",
          data: this.xData,
          axisLine: {
            lineStyle: {
              color: "#8c9493",
            },
          },
          axisLabel: {
            // interval: 0,
            // rotate: 40,
            textStyle: {
              fontFamily: "Microsoft YaHei",
              // fontWeight: 600,
              fontSize: 14,
            },
          },
        },

        yAxis: {
          name: "MWh",
          nameTextStyle: {
            // color: "#fff"
          },
          type: "value",
          max: "150",
          axisLine: {
            show: true,
            lineStyle: {
              // color: '#8c9493'
            },
          },
          splitLine: {
            show: false,
            lineStyle: {
              color: "#8c9493",
            },
          },
          axisLabel: {
            textStyle: {
              // fontWeight: 600
            },
          },
        },
        series: [
          {
            name: "充电量",
            type: "bar",
            barWidth: "25%",
            itemStyle: {
              normal: {
                color: "rgb(76,197,176)",
              },
            },
            data: [10, 30, 40, 120, 50, 90, 60, 40, 15, 60, 30, 15],
          },
          {
            name: "放电量",
            type: "bar",
            barWidth: "25%",
            itemStyle: {
              normal: {
                color: "rgb(177,221,168)",
              },
            },
            data: [5, 40, 60, 110, 40, 100, 70, 50, 20, 110, 40, 10],
          },
        ],
      };
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
    /**
     * @Description: 关闭dialog
     * @Author: 赵程成
     */
    closeDialog() {
      this.detailObj = null;
      this.queryLoading = true;
    },
    /**
     * @Description: 查询接口
     * @Author: 赵程成
     */
    //   queryData(obj, str) {
    //     this.queryLoading = true;
    //     this.tableDataLoading = true;
    //     let data = {
    //       dadx: str,
    //       ...obj,
    //     };
    //     queryBaseInfo(data)
    //       .then((res) => {
    //         if (res.data.code === 200) {
    //           this.detailList = tabledetail[str];
    //           this.tableOtherDetailList = tableOtherDetail[str];
    //           this.tableZCDetailList = tableZCDetail[str];
    //           this.detailObj = res.data.data;
    //           this.descriptionsKey++;
    //         }
    //         this.queryLoading = false;
    //         this.tableDataLoading = false;
    //       })
    //       .catch((err) => {
    //         console.log(err);
    //         this.queryLoading = false;
    //         this.tableDataLoading = false;
    //       });
    //   },
    resetForm() {
      this.$refs["form"].resetFields();
    },
    cancel() {
      this.$emit("update:dialogVisible", false);
    },
    handleSizeChange(e) {
      this.queryForm.pageNum = 1;
      this.queryForm.pageSize = e;
      this.queryData();
    },
    handleCurrentChange(e) {
      this.queryForm.pageNum = e;
      this.queryData();
    },
  },
};
</script>
  
  <style lang="scss" scoped>
::v-deep .el-descriptions .descriptions-view .descriptions-item-content {
  width: 30%;
}

::v-deep .el-descriptions .descriptions-view .descriptions-row > td {
  padding-bottom: 5px !important;
}

::v-deep .el-descriptions .descriptions-view .descriptions-row > th {
  padding-bottom: 5px !important;
}

::v-deep .el-button--medium {
  padding: 0px;
}
LS {
  word-break: keep-all;
}

CS {
  max-width: 300px;
  word-break: keep-all;
}

.el-dropdown-link {
  cursor: pointer;
  color: #3c6cfe;
}
.operate-btn {
  padding-left: 20px;
}
.el-input {
  width: fit-content;
}
.query-table {
  height: calc(100% - 102px);
}
.query-pagination {
  margin-top: 20px;
  text-align: right;
}
.fileSynchronization-detail {
  ::v-deep .el-title {
    margin-bottom: 24px !important;
  }
  ::v-deep .el-dialog__body {
    height: calc(100% - 170px);
    // max-height: 425px;
    overflow: auto;
    padding: 0 24px !important;
    .dialog-content {
      // 时间范围宽度
      ::v-deep .el-range-editor--small {
        width: 100%;
      }
      ::v-deep .el-date-editor--date {
        width: 100%;
      }
    }
  }
}
.model-view {
  width: 100%;
  height: 100%;

  overflow-y: auto;
  // border-bottom: 1px solid #eee;

  .title-view {
    display: flex;
    align-items: center;
    .title-line {
      width: 4px;
      height: 16px;
      background: #3c6cfe;
      margin-right: 8px;
    }
  }

  .child_right {
    // @include child_left;
    width: 100%;
    height: 30%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    // margin-top: 20%;
  }

  .underTitle2 {
    width: 100%;
    display: flex;
    flex-direction: row;
    // justify-content: space-between;
    align-content: center;
    flex-wrap: wrap;

    > div:nth-child(n) {
      width: 45%;
      height: 40%;
      display: flex;
      background: rgb(245, 245, 245);
      border-radius: 10px;
      justify-content: center;
      align-items: center;
      margin: 1%;
      margin-left: 3%;
    }
    // > div:nth-child(2) {
    //   width: 69%;
    //   height: 100%;
    // }
  }

  .child_left1 {
    height: 80%;
    width: 25%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url("@/assets/images/sjcdwl/本月充电总量.png");
  }

  .content-view {
    padding-bottom: 24px;
    > div:nth-child(1) {
      height: 700px;
      display: flex;
      flex-direction: column;
      > div:nth-child(1) {
        height: 20%;
        width: 100%;
        display: flex;
        flex-direction: column;
        > div:nth-child(1) {
          height: 20%;
          width: 100%;
        }
        > div:nth-child(2) {
          height: 80%;
          width: 90%;
          display: flex;
          flex-direction: column;
          margin: 0 auto;
          justify-content: space-around;
        }
      }
      > div:nth-child(2) {
        height: 80%;
        width: 100%;
        display: flex;
        flex-direction: column;
        > div:nth-child(1) {
          width: 100%;
          height: 70%;
          display: flex;
          flex-direction: row;
          > div:nth-child(1) {
            width: 50%;
            height: 100%;
          }
          > div:nth-child(2) {
            width: 50%;
            height: 100%;
          }
        }
        > div:nth-child(2) {
          width: 100%;
          height: 30%;
        }
      }
    }
  }
}
</style>
  